package common.db.io;

import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: Paskal
 * Date: May 8, 2009
 * Time: 7:58:13 PM
 * To change this template use File | Settings | File Templates.
 */

public class InputFile {
	private DataInputStream input;

	 public InputFile(String filename) throws FileNotFoundException {
	   input = new DataInputStream(new FileInputStream(filename));
	 }

	 public void close()throws IOException{
		 input.close();
	 }
	 public String getLine() throws IOException {
	   return input.readLine();
	 }

	 public String getWord()throws IOException{
		 int c;
		 StringBuffer buf=new StringBuffer();
		 while((c = input.read())!=-1){
		     if (Character.isSpaceChar(c)||(Character.isWhitespace(c)))
		    	 return buf.toString();
		     else
		    	 buf.append((char) c);
		 }
		 //when EOF return null
		 if(c==-1 && buf.length()==0)return null;
		 return buf.toString();
	 }
}
